<!-- start scripts -->
<script src="<?php echo $ruta;?>/js/jquery-1.7.1.min.js"></script>
<script src="<?php echo $ruta;?>/js/jquery.cycle.all.min.js"></script>
<script src="<?php echo $ruta;?>/js/jquery.easing.1.3.js"></script>
<script src="<?php echo $ruta;?>/js/jquery.fancybox-1.3.4.pack.js"></script>
<script src="<?php echo $ruta;?>/js/custom.js"></script>
<script src="<?php echo $ruta;?>/js/general.js"></script>
<script src="<?php echo $ruta;?>/js/organictabs.jquery.js"></script>
<script src="<?php echo $ruta;?>/js/jquery-ui-1.8.18.custom.min.js"></script>

<script src="<?php echo $ruta;?>/js/jquery.ui.datepicker-es.js"></script>
<script src="<?php echo $ruta;?>/js/ui.dropdownchecklist-1.4-min.js"></script>

<style type="text/css">
	.ui-autocomplete {
		max-height: 200px;
		overflow-y: auto;
		/* prevent horizontal scrollbar */
		overflow-x: hidden;
		/* add padding to account for vertical scrollbar */
		padding-right: 20px;
	}
        
        .ui-dropdownchecklist-text {
            color: #b70e4f;
            font-weight: bold;
        }        
</style>

<script type="text/javascript">
$(function(){ 
    $(".datepicker").datepicker( $.datepicker.regional[ "es" ] );
    $( "#format" ).change(function() {
        $( ".datepicker" ).datepicker( "option", "dateFormat", 'dd/mm/yyyy' );
    });
    var dates = $( "#datefrom, #dateto" ).datepicker({
        changeMonth: true,
        numberOfMonths: 1,
        minDate: '+1d',
        onSelect: function( selectedDate ) {
            var option = this.id == "datefrom" ? "minDate" : "maxDate",
                    instance = $( this ).data( "datepicker" ),
                    date = $.datepicker.parseDate(
                            instance.settings.dateFormat ||
                            $.datepicker._defaults.dateFormat,
                            selectedDate, instance.settings );
                    date.setDate(date.getDate()+1);
            dates.not( this ).datepicker( "option", option, date );
        }
    });    
    $("#example-one").organicTabs();
    var count_playa = 0;
    var count_ciudad = 0;
    var count_rural = 0;
    var count_nieve = 0;
    $("input[name='pro_pi_fianza']").change(function(){
        if($("input[name='pro_pi_fianza']:checked").val() == 0){
            $("#tit_pro_impfianza").html('<?php echo lang('pro_fianzapct');?>');
        }else{
            $("#tit_pro_impfianza").html('<?php echo lang('pro_impfianza');?>');
        }
    });
    $("input[name='pro_pi_reserva']").change(function(){
        if($("input[name='pro_pi_reserva']:checked").val() == 0){
            $("#tit_pro_impreserva").html('<?php echo lang('pro_reservapct');?>');
        }else{
            $("#tit_pro_impreserva").html('<?php echo lang('pro_impreserva');?>');
        }
    });
    $("#enlace_mapa").click(function(){
        $.ajax({
            type: "POST",
            url: '<?php echo site_url('busqueda/mapa');?>',
            data: {},
            success: function(datos){
                alert(datos);
                $('#map_canvas').html(datos);
            }
        });
    });
    $("#img_playa").click(function(){
        $(this).toggleClass("borde-lila");
        count_playa++;
        if(count_playa % 2 == 1){
            $("#p_entorno_playa").val("S");
            $("#p_entorno_ciudad").val("N");
            $("#p_entorno_rural").val("N");
            $("#p_entorno_nieve").val("N");
        }else{
            $("#p_entorno_playa").val("N");
        }
    });
    $("#img_ciudad").click(function(){
        $(this).toggleClass("borde-lila");
        count_ciudad++;
        if(count_ciudad % 2 == 1){
            $("#p_entorno_ciudad").val("S");
            $("#p_entorno_playa").val("N");
            $("#p_entorno_rural").val("N");
            $("#p_entorno_nieve").val("N");
        }else{
            $("#p_entorno_ciudad").val("N");
        }
    });
    $("#img_rural").click(function(){
        $(this).toggleClass("borde-lila");
        count_rural++;
        if(count_rural % 2 == 1){
            $("#p_entorno_rural").val("S");
            $("#p_entorno_playa").val("N");
            $("#p_entorno_ciudad").val("N");
            $("#p_entorno_nieve").val("N");
        }else{
            $("#p_entorno_rural").val("N");
        }
    });
    $("#img_nieve").click(function(){
        $(this).toggleClass("borde-lila");
        count_nieve++;
        if(count_nieve % 2 == 1){
            $("#p_entorno_nieve").val("S");
            $("#p_entorno_playa").val("N");
            $("#p_entorno_ciudad").val("N");
            $("#p_entorno_rural").val("N");
        }else{
            $("#p_entorno_nieve").val("N");
        }
    });
});

$(document).ready(function() {
    $("#p_lugares").css("display","inline");
    $("#p_lugares").dropdownchecklist( {
        icon: {}, 
        width: 250, 
        emptyText: '<?php echo lang('por_favor_seleccione');?>', 
        maxDropHeight: 200,
        onComplete: function(selector) {
            var values = "";
            for( i=0; i < selector.options.length; i++ ) {
                if (selector.options[i].selected && (selector.options[i].value != "")) {
                    if ( values != "" ) values += ",";
                    values += selector.options[i].value;
                }
            }
            $("#p_valores_lugares").val(values);
        } 
    } );
    $("#pro_provincia").change(function () {
        $.post('<?php echo site_url('producto/getMunicipios'); ?>', { provincia: $(this).val() }, function(data){
            $("#pro_municipio").html(data);
        });
    })    
});


</script>

<!--[if IE]> <script src="<?php echo $ruta;?>/js/selectivizr.js"></script> <![endif]-->
<!-- end scripts -->
